<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8"><meta name="referrer" content="no-referrer" />
    <title>个人中心界面</title>
    <script src="js/jquery-1.11.0.min.js"></script>
    <link href="css/bootstrap.min.css" rel="stylesheet">
    <link href="css/materialdesignicons.min.css" rel="stylesheet">
    <link href="css/style.min.css" rel="stylesheet">
    <style>
        .left-side {
            position: fixed;
            top: 0;
            bottom: 0;
            z-index: 5;
            display: block;
            width: 240px;
            font-weight: 500;
        }

        .submenu > ul {
            display: none;
        }

        .open > ul {
            display: block;
        }
    </style>
    <script>
        $(function () {
            console.log("进入头部");
            $(".header").load("headHtml");
            $.post("/getUserName", function (obj) {
                if (obj != null && obj != 100) {
                    $.ajax({
                        url: "/getTitle",
                        type: "POST",
                        success: function (result) {
                            console.log("---------");
                            console.log(result);
                            console.log("---------");
                            if (result.length > 0) {
                                $imgs = $("#navul");
                                var li = '';
                                for (let i = 0; i < result.length; i++) {
                                    result[i].date = rTime(result[i].date);
                                    li = li + '<tr>\n' +
                                        '<th>' + (i + 1) + '</th>\n' +
                                        '<th>' + result[i].title + '</th>\n';
                                    li = li + '<th>' + result[i].date + '</th>\n';
                                    li = li + '</tr>';
                                }
                                $imgs.html(li);
                            } else {
                                $imgs = $("#titles");
                                var li = '<p style="font-size: 50px">您还未爬取过任何主题哦！赶紧搜索喜欢的图片吧！</p>';
                                $imgs.html(li);
                            }
                        }
                    })
                } else {
                    if (confirm("您还未登录，是否先登录？")) {
                        console.log("您选择了是");
                        window.location.href = "loginHtml";
                    } else {
                        console.log("您选择了否");
                        window.location.href = "record";
                    }
                }
            }, "json");
        });
        function moren(){
            $.ajax({
                url: "/getTitle",
                type: "POST",
                success: function (result) {
                    console.log("---------");
                    console.log(result);
                    console.log("---------");
                    if (result.length > 0) {
                        $imgs = $("#navul");
                        var li = '';
                        for (let i = 0; i < result.length; i++) {
                            result[i].date = rTime(result[i].date);
                            li = li + '<tr>\n' +
                                '<th>' + (i + 1) + '</th>\n' +
                                '<th>' + result[i].title + '</th>\n';
                            li = li + '<th>' + result[i].date + '</th>\n';
                            li = li + '</tr>';
                        }
                        $imgs.html(li);
                    } else {
                        $imgs = $("#titles");
                        var li = '<p style="font-size: 50px">您还未爬取过任何主题哦！赶紧搜索喜欢的图片吧！</p>';
                        $imgs.html(li);
                    }
                }
            })
        }
        function sheng(){
            $.ajax({
                url: "/shengxu",
                type: "POST",
                success: function (result) {
                    console.log("---------");
                    console.log(result);
                    console.log("---------");
                    if (result.length > 0) {
                        $imgs = $("#navul");
                        var li = '';
                        for (let i = 0; i < result.length; i++) {
                            result[i].date = rTime(result[i].date);
                            li = li + '<tr>\n' +
                                '<th>' + (i + 1) + '</th>\n' +
                                '<th>' + result[i].title + '</th>\n';
                            li = li + '<th>' + result[i].date + '</th>\n';
                            li = li + '</tr>';
                        }
                        $imgs.html(li);
                    } else {
                        $imgs = $("#titles");
                        var li = '<p style="font-size: 50px">您还未爬取过任何主题哦！赶紧搜索喜欢的图片吧！</p>';
                        $imgs.html(li);
                    }
                }
            })
        }
        function jiang(){
            $.ajax({
                url: "/jiangxu",
                type: "POST",
                success: function (result) {
                    console.log("---------");
                    console.log(result);
                    console.log("---------");
                    if (result.length > 0) {
                        $imgs = $("#navul");
                        var li = '';
                        for (let i = 0; i < result.length; i++) {
                            result[i].date = rTime(result[i].date);
                            li = li + '<tr>\n' +
                                '<th>' + (i + 1) + '</th>\n' +
                                '<th>' + result[i].title + '</th>\n';
                            li = li + '<th>' + result[i].date + '</th>\n';
                            li = li + '</tr>';
                        }
                        $imgs.html(li);
                    } else {
                        $imgs = $("#titles");
                        var li = '<p style="font-size: 50px">您还未爬取过任何主题哦！赶紧搜索喜欢的图片吧！</p>';
                        $imgs.html(li);
                    }
                }
            })
        }
        function rTime(date) {
            var json_date = new Date(date).toJSON();
            return new Date(new Date(json_date) + 8 * 3600 * 1000).toISOString().replace(/T/g, ' ').replace(/\.[\d]{3}Z/, '')
        }
    </script>
    <script>
        $(function () {
            $('.submenu').mouseover(function () {
                $(this).addClass('open');
            }).mouseout(function () {
                $(this).removeClass('open');
            });
        })
    </script>
</head>
<body>
<div class="lyear-layout-web">
    <div class="lyear-layout-container">
        <!--左侧导航-->
        <aside class="lyear-layout-sidebar">
            <!-- logo -->
            <div id="logo" class="sidebar-header">
                <h1 style="text-align: center;color: #33cabb;">Spider</h1>
            </div>
            <div class="lyear-layout-sidebar-scroll">
                <nav class="sidebar-main">
                    <ul class="nav nav-drawer" style="list-style: none">
                        <li class="nav-item active"><a href="/notice"><i class="mdi mdi-home"></i>公告栏</a></li>
                        <li class="nav-item active"><a href="/index"><i class="mdi mdi-home"></i>爬取图片</a></li>
                        <li class="nav-item active"><a href="/displayHtml"><i class="mdi mdi-home"></i>我的收藏</a></li>
                        <li class="nav-item active"><a href="/share"><i class="mdi mdi-home"></i>好图分享</a></li>
                        <li class="nav-item active submenu"><a href="#"><i class="mdi mdi-home"></i>个人中心</a>
                            <ul class="nav nav-drawer">
                                <li class="nav-item active"><a href="/self">&nbsp&nbsp&nbsp&nbsp<i
                                        class="mdi mdi-step-forward"></i>信息编辑</a></li>
                                <li class="nav-item active"><a href="/record">&nbsp&nbsp&nbsp&nbsp<i
                                        class="mdi mdi-step-forward"></i>爬取记录</a></li>
                                <li class="nav-item active"><a href="/comment">&nbsp&nbsp&nbsp&nbsp<i class="mdi mdi-step-forward"></i>评论反馈</a></li>

                            </ul>
                        </li>
                    </ul>
                </nav>
            </div>
        </aside>
        <!--End 左侧导航-->
        <!--头部信息-->
        <div class="header"></div>
        <!--End 头部信息-->
        <!-- 主题内容 -->
        <!--页面主要内容 table table-striped table-hover-->
        <main class="lyear-layout-content">
            <div class="container-fluid">
                <div class="row">
                    <div class="col-lg-12">
                        <button onclick="moren()">默认排序</button><button onclick="sheng()">按时间升序</button><button onclick="jiang()">按时间降序</button>
                        <div class="card">
                            <form action="/spider" method="post">
                                <table class="table table-bordered">
                                    <thead>
                                    <tr>
                                        <th>编号</th>
                                        <th>主题</th>
                                        <th>日期</th>
                                    </tr>
                                    </thead>
                                    <tbody id="navul">

                                    </tbody>
                                </table>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </main>
        <!--End 页面主要内容-->
    </div>
</div>
</body>
</html>